Duplicate Assert ^^^^^ **Definition:** * This smell occurs when a test method tests for the same condition multiple times within the same test method. If the test method needs to test the same condition using different values, a new test method should be created. As a best practice, the name of the test method should be an indication of the test being performed. Possible situations that would give rise to this smell include (1) developers grouping multiple conditions to test a single method, (2) developers performing debugging activities, and (3) an accidental copy-paste of code **Code Example:** .. code-block:: java @Test public void testXmlSanitizer() { boolean valid = XmlSanitizer.isValid("Fritzbox"); assertEquals("Fritzbox is valid", true, valid); System.out.println("Pure ASCII test - passed"); valid = XmlSanitizer.isValid("Fritz Box"); assertEquals("Spaces are valid", true, valid); System.out.println("Spaces test - passed"); valid = XmlSanitizer.isValid("Frützbüx"); assertEquals("Frützbüx is invalid", false, valid); System.out.println("No ASCII test - passed"); valid = XmlSanitizer.isValid("Fritz!box"); assertEquals("Exclamation mark is valid", true, valid); System.out.println("Exclamation mark test - passed"); valid = XmlSanitizer.isValid("Fritz.box"); assertEquals("Exclamation mark is valid", true, valid); System.out.println("Dot test - passed"); valid = XmlSanitizer.isValid("Fritz-box"); assertEquals("Minus is valid", true, valid); System.out.println("Minus test - passed"); valid = XmlSanitizer.isValid("Fritz-box"); assertEquals("Minus is valid", true, valid); System.out.println("Minus test - passed"); } **References:** .. admonition:: Quality attributes * :octicon:`file-code;1em` - Code Example * :octicon:`comment-discussion;1em` - Cause and Effect * :octicon:`graph;1em` - Frequency * :octicon:`sync;1em` - Refactoring * `An Exploratory Study on the Refactoring of Unit Test Files in Android Applications `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em` * `Analyzing Test Smells Refactoring from a Developers Perspective `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em` :octicon:`sync;1em` * `Automatic Identification of High-Impact Bug Report by Product and Test Code Quality `_ * `Automatic generation of smell-free unit tests `_ :octicon:`file-code;1em` :octicon:`comment-discussion;1em` * `Characterizing High-Quality Test Methods: A First Empirical Study `_ :octicon:`graph;1em` * `Characterizing High-Quality Test Methods: A First Empirical Study `_ :octicon:`graph;1em` * `Handling Test Smells in Python: Results from a Mixed-Method Study `_ * `Investigating Test Smells in JavaScript Test Code `_ :octicon:`graph;1em` * `On the Distribution of "Simple Stupid Bugs" in Unit Test Files: An Exploratory Study `_ * `On the diffusion of test smells and their relationship with test code quality of Java projects `_ :octicon:`graph;1em` * `On the distribution of test smells in open source Android applications: an exploratory study `_ :octicon:`file-code;1em` :octicon:`graph;1em` * `On the influence of Test Smells on Test Coverage `_ * `On the test smells detection: an empirical study on the jnose test accuracy `_ :octicon:`graph;1em` * `On the use of test smells for prediction of flaky tests `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em` * `PyNose: A Test Smell Detector For Python `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em` * `Pytest-Smell: a smell detection tool for Python unit tests `_ :octicon:`graph;1em` * `RAIDE: a tool for Assertion Roulette and Duplicate Assert identification and refactoring `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em` * `Refactoring Test Smells With JUnit 5: Why Should Developers Keep Up-to-Date? `_ :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`graph;1em` :octicon:`sync;1em` * `Software Unit Test Smells `_ :octicon:`file-code;1em` * `Test Smell Detection Tools: A Systematic Mapping Study `_ * `The secret life of test smells-an empirical study on test smell evolution and maintenance `_ :octicon:`graph;1em` * `Understanding practitioners’ strategies to handle test smells: a multi-method study `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em` * `What the Smell? An Empirical Investigation on the Distribution and Severity of Test Smells in Open Source Android Applications `_ :octicon:`file-code;1em` :octicon:`graph;1em` * `tsDetect: an open source test smells detection tool `_